using MediatR;
using ProduceBasicData.Domain.WarehouseManage.WarehouseEnum;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Application.Command.WarehouseManage
{
    /// <summary>
    /// 创建入库单命令
    /// </summary>
    public class CreateStockInOrderCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 系统编码
        /// </summary>
        public string? OrderNumber { get; set; }

        /// <summary>
        /// 入库类型
        /// </summary>
        public StockInType InType { get; set; }

        /// <summary>
        /// 关联单号 (如采购单号、生产单号等)
        /// </summary>
        public string? RelatedOrderNumber { get; set; }

        /// <summary>
        /// 目标仓库ID
        /// </summary>
        public int? WarehouseId { get; set; }

        /// <summary>
        /// 供应商ID
        /// </summary>
        public int? SupplierId { get; set; }

        /// <summary>
        /// 供应商名称
        /// </summary>
        public string? SupplierName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public StockInStatus Status { get; set; } = StockInStatus.Pending;

        /// <summary>
        /// 预计入库日期
        /// </summary>
        public DateTime? ExpectedInDate { get; set; }

        /// <summary>
        /// 实际入库日期
        /// </summary>
        public DateTime? ActualInDate { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreateName { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 入库单明细
        /// </summary>
        public List<CreateStockInOrderItemCommand>? Items { get; set; }
    }

    /// <summary>
    /// 创建入库单明细命令
    /// </summary>
    public class CreateStockInOrderItemCommand
    {
        /// <summary>
        /// 系统编码
        /// </summary>
        public string? SytemNo { get; set; }
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int StockInOrderId { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public int MaterialId { get; set; }

        /// <summary>
        /// 物料编号
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string? Specification { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string? Unit { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        public decimal PlannedQuantity { get; set; }

        /// <summary>
        /// 实际数量
        /// </summary>
        public decimal ActualQuantity { get; set; }

        /// <summary>
        /// 批次号
        /// </summary>
        public string? BatchNumber { get; set; }

        /// <summary>
        /// 生产日期
        /// </summary>
        public DateTime? ProductionDate { get; set; }

        /// <summary>
        /// 有效期至
        /// </summary>
        public DateTime? ExpirationDate { get; set; }

        /// <summary>
        /// 目标库位ID
        /// </summary>
        public int? TargetLocationId { get; set; }

        /// <summary>
        /// 目标库位编号
        /// </summary>
        public string? TargetLocationCode { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreateName { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;
    }
}